package com.ruoyi.basebill.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basebill.domain.TWfzGzff;
import com.ruoyi.basebill.service.ITWfzGzffService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工资发放Controller
 *
 * @author ruoyi
 * @date 2022-12-14
 */


/**
 * 已废弃，由 WfzGzffController 替代
 */










@RestController
@RequestMapping("/basebill1/gzff")
public class TWfzGzffController extends BaseController
{
    @Autowired
    private ITWfzGzffService tWfzGzffService;

    /**
     * 查询工资发放列表
     */
    @PreAuthorize("@ss.hasPermi('basebill:gzff:list')")
    @GetMapping("/list")
    public TableDataInfo list(TWfzGzff tWfzGzff)
    {
        startPage();
        List<TWfzGzff> list = tWfzGzffService.selectTWfzGzffList(tWfzGzff);
        return getDataTable(list);
    }

    /**
     * 导出工资发放列表
     */
    @PreAuthorize("@ss.hasPermi('basebill:gzff:export')")
    @Log(title = "工资发放", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TWfzGzff tWfzGzff)
    {
        List<TWfzGzff> list = tWfzGzffService.selectTWfzGzffList(tWfzGzff);
        ExcelUtil<TWfzGzff> util = new ExcelUtil<TWfzGzff>(TWfzGzff.class);
        util.exportExcel(response, list, "工资发放数据");
    }

    /**
     * 获取工资发放详细信息
     */
    @PreAuthorize("@ss.hasPermi('basebill:gzff:query')")
    @GetMapping(value = "/{fid}")
    public AjaxResult getInfo(@PathVariable("fid") Long fid)
    {
        return success(tWfzGzffService.selectTWfzGzffByFid(fid));
    }

    /**
     * 新增工资发放
     */
    @PreAuthorize("@ss.hasPermi('basebill:gzff:add')")
    @Log(title = "工资发放", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TWfzGzff tWfzGzff)
    {
        //获取当前登录用户的用户名，并且设置到制单人属性中
        tWfzGzff.setFcreator(getUsername());
        //获取当前登录用户的用户名，并且设置到修改人属性中
        tWfzGzff.setFlastupdateuser(getUsername());
        return toAjax(tWfzGzffService.insertTWfzGzff(tWfzGzff));
    }

    /**
     * 修改工资发放
     */
    @PreAuthorize("@ss.hasPermi('basebill:gzff:edit')")
    @Log(title = "工资发放", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TWfzGzff tWfzGzff)
    {
        //获取当前登录用户的用户名，并且设置到修改人属性中
        tWfzGzff.setFlastupdateuser(getUsername());
        return toAjax(tWfzGzffService.updateTWfzGzff(tWfzGzff));
    }

    /**
     * 删除工资发放
     */
    @PreAuthorize("@ss.hasPermi('basebill:gzff:remove')")
    @Log(title = "工资发放", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fids}")
    public AjaxResult remove(@PathVariable Long[] fids)
    {
        return toAjax(tWfzGzffService.deleteTWfzGzffByFids(fids));
    }
}
